export const areaCode = (() => {
  const areaTypeEnum = { 4: 'area', 5: 'street', 6: 'community' };

  function getAreaType(area_code) {
    const len = area_code ? area_code.split('.').length : 0;
    return areaTypeEnum[len];
  }

  function isArea(area_code) {
    return getAreaType(area_code) === 'area';
  }

  function isStreet(area_code) {
    return getAreaType(area_code) === 'street';
  }

  function isCommunity(area_code) {
    return getAreaType(area_code) === 'community';
  }

  return {
    getAreaType,
    isArea,
    isStreet,
    isCommunity,
  };
})();
